﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using RestfulApi.Filters;

namespace RestfulApi.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class TestFilterController : ControllerBase
    {
        public ILogger<TestFilterController> logger { set; get; }

        public TestFilterController(ILogger<TestFilterController> logger)
        {
            logger = logger;
        }

        [TypeFilter(typeof(MyActionFilterAttribute))]
        [TypeFilter(typeof(MyAuthorizationFilterAttribute))]
        [TypeFilter(typeof(MyResourceFilterAttribute))]
        [TypeFilter(typeof(MyExceptionFilterAttribute))]
        [TypeFilter(typeof(MyResultFilterAttribute))]
        [HttpGet]
        public IActionResult Index()
        {
            new Exception("Test Exception Filter Index");
            return Ok("TestFilterController.Index called");
        }
    }
}
